package com.tjetc.view.manage;

import com.tjetc.domain.Newborn;
import com.tjetc.domain.Vaccination;
import com.tjetc.domain.Vaccine;
import com.tjetc.proxy.ClientProxy;
import com.tjetc.service.DoctorService;
import com.tjetc.service.VaccineService;
import com.tjetc.vo.Result;

import com.tjetc.vo.AppDate;

import java.util.Date;
import java.util.List;
import java.util.Scanner;

public class VaccinationView {
    private Scanner scanner=new Scanner(System.in);
    private DoctorService doctorService= ClientProxy.getProxyInstance(DoctorService.class);
    private VaccineService vaccineService=ClientProxy.getProxyInstance(VaccineService.class);
    public void start() {
        while (true){
            try {
                System.out.println("1.查询本人进行疫苗接种情况");
                System.out.println("2.对新生儿接种疫苗信息更新");
                System.out.println("3.查询疫苗库存");
                System.out.println("0.返回上一级");
                System.out.println("请输入对应的编号(0~8)");
                int i = scanner.nextInt();
                switch (i){
                    case 1:
                        yimiaolist();
                        break;
                    case 2:
                        yimiaojiehzong();
                        break;
                    case 3:
                        buchong();
                        break;
                    case 0:
                        return;
                }
            } catch (Exception e) {
                System.out.println("输入错误,请重新输入");
                scanner.nextLine();
            }
        }
    }

    private void buchong() {
        List<Vaccine> list=vaccineService.list();
        for (Vaccine vaccine : list) {
            System.out.println(vaccine);
        }
    }
    private void yimiaojiehzong() {
        int id=AppDate.loginDoctor.getId();
        List<Vaccination> list=doctorService.yimiaoList(id);
        if (list==null){
            System.out.println("暂无信息");
        }else {
            for (Vaccination vaccination : list) {
                if (vaccination.getJiezhongTime()==null){
                    System.out.println(vaccination);
                }
            }
            System.out.println("请输入选择更新的信息编号");
            int i = scanner.nextInt();
            Result result=doctorService.upd1(i);
            System.out.println(result.getMsg());
        }
    }

    private void yimiaolist() {
        int id=AppDate.loginDoctor.getId();
        List<Vaccination> list=doctorService.yimiaoList(id);
        if (list==null){
            System.out.println("暂无信息");
        }else {
            for (Vaccination vaccination : list) {
                System.out.println(vaccination);
            }
        }
    }

}
